#ifndef CHATDIALOG_H
#define CHATDIALOG_H

#include <QDialog>
class QListWidget;
class QListWidgetItem;
class QTimer;

class QTextEdit;
class QLineEdit;
class QPushButton;

class ChatDialog : public QDialog
{
    Q_OBJECT
public:
    explicit ChatDialog(const QString &userName, QWidget *parent = nullptr);

    void setPeer(ChatDialog *peerDialog);

signals:
    void outgoingMessage(const QString &senderName, const QString &messageText);

public slots:
    void receiveMessage(const QString &senderName, const QString &messageText);

private slots:
    void handleSend();

private:
    void appendMessageBubble(bool isSelf, const QString &name, const QString &text);
    void maybeInsertTimeSeparator();

private:
    QString m_userName;
    ChatDialog *m_peer;

    // UI elements
    QListWidget *m_listView;
    QLineEdit *m_inputEdit;
    QPushButton *m_sendButton;
    QTimer *m_inactivityTimer;
    bool m_shouldShowNextTime;
};

#endif // CHATDIALOG_H


